/*
 * Carlos René Michel Morales
 * 
 * Clase para el manejo de los datos "User" del API de twitter
 */

package piticli.twitter;

import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;

import org.json.*;
/**
 *
 * @author Rene
 */
public class User {
    private Long id;
    private String name;
    private String screen_name;
    private String location;
    private String description;
    private String profile_image_url;
    private String url;
    private boolean protectd;
    private int followers_count;
    private String profile_background_color;
    private String profile_text_color;
    private String profile_link_color;
    /*Llenar las demas propiedades del api*/
    private int friends_count;
    private String created_at; //Usar .parse para sacar un objeto date de un String
    private int favorites_count;
    private int statuses_count;
    private boolean following;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getScreen_name() {
        return screen_name;
    }

    public void setScreen_name(String screen_name) {
        this.screen_name = screen_name;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getProfile_image_url() {
        return profile_image_url;
    }

    public void setProfile_image_url(String profile_image_url) {
        this.profile_image_url = profile_image_url;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public boolean isProtectd() {
        return protectd;
    }

    public void setProtectd(boolean protectd) {
        this.protectd = protectd;
    }

    public int getFollowers_count() {
        return followers_count;
    }

    public void setFollowers_count(int followers_count) {
        this.followers_count = followers_count;
    }

    public String getProfile_background_color() {
        return profile_background_color;
    }

    public void setProfile_background_color(String profile_background_color) {
        this.profile_background_color = profile_background_color;
    }

    public String getProfile_text_color() {
        return profile_text_color;
    }

    public void setProfile_text_color(String profile_text_color) {
        this.profile_text_color = profile_text_color;
    }

    public String getProfile_link_color() {
        return profile_link_color;
    }

    public void setProfile_link_color(String profile_link_color) {
        this.profile_link_color = profile_link_color;
    }

    public int getFriends_count() {
        return friends_count;
    }

    public void setFriends_count(int friends_count) {
        this.friends_count = friends_count;
    }

    public String getCreated_at() {
        return created_at;
    }

    public void setCreated_at(String created_at) {
        this.created_at = created_at;
    }

    public int getFavorites_count() {
        return favorites_count;
    }

    public void setFavorites_count(int favorites_count) {
        this.favorites_count = favorites_count;
    }

    public int getStatuses_count() {
        return statuses_count;
    }

    public void setStatuses_count(int statuses_count) {
        this.statuses_count = statuses_count;
    }

    public boolean isFollowing() {
        return following;
    }

    public void setFollowing(boolean following) {
        this.following = following;
    }
    
    public static User getUserFromJSONObject(JSONObject obj) throws JSONException, ParseException{
        User retUser = new User();
        
        retUser.id = obj.getLong("id");
        retUser.description = obj.getString("description").toString();
        //DateFormat aux = null;
        retUser.created_at = obj.getString("created_at").toString(); //Mejorar Fecha
        //created_at.parse(obj.getString("created_at"));
        retUser.followers_count = obj.getInt("followers_count");
        //retUser.following = obj.getBoolean("following"); //Marca que no es de tipo booleano :S ????
        retUser.location = obj.getString("location").toString();
        retUser.name = obj.getString("name").toString();
        retUser.protectd = obj.getBoolean("protected");
        retUser.screen_name = obj.getString("screen_name").toString();
        retUser.statuses_count = obj.getInt("statuses_count");
        retUser.profile_image_url = obj.getString("profile_image_url").toString();
        retUser.profile_link_color = obj.getString("profile_link_color").toString();
        retUser.profile_text_color = obj.getString("profile_text_color").toString();
        retUser.url = obj.getString("url").toString();
        
        return retUser;
    }
    
}
